﻿using System;
using FarmerJoe.Helpers;
using FarmerJoe.Helpers.Logging;
using Styx;
using Styx.CommonBot;
using Styx.TreeSharp;
using Action = Styx.TreeSharp.Action;

namespace FarmerJoe.Classes
{
    public static partial class Warlock
    {
        public static Composite CombatBehavior_LowLevel
        {
            get
            {
                return new PrioritySelector(

                    Spells.WaitForCast(),
                    Misc.EnsureTarget(),

                    Movement.MoveToLOS(),
                    Movement.FaceTarget(),
                    Movement.ForceFacingTarget(),
                    Movement.Fixes(),
                    SummonPet(),

                    // Somehow we've got a target that is not hostile or attackable. Blacklist it and move on
                    new Decorator(ret => !CT.Attackable || CT.IsFriendly,
                        new Sequence(
                            new Action(context => Log.Write(Colours.InformativeColour, "Somehow we've got a target that is friendly or not attackable, blacklisting it and moving on.")),
                            new Action(context => Blacklist.Add(CT, TimeSpan.FromMinutes(1))),
                            new Action(context => Me.ClearTarget())
                        )),

                    // Combat
                    
                    Spells.Cast("Corruption", ret=> !CT.HasMyAura("Corruption")),
                    Spells.Cast("Drain Life", ret=> Me.HealthPercent < 70),

                    Spells.Cast("Shadow Bolt"),
                    Movement.MoveToTarget(true, 35f)


                    );
            }
        }
    }
}
